<?php

class Application_Model_DbTable_Temptaobaoitems extends Zend_Db_Table_Abstract
{

    protected $_name = 'txy_temp_taobao';
	
    public function addNewTempTaobaoItems($item){
    	$data=array(
    		'taobao_num_iid'=>$item->num_iid,
    		'taobao_title'=>$item->title,
    		'taobao_nick'=>$item->nick,
	    	'taobao_pic_url'=>$item->pic_url,
    		'taobao_pic_url'=>$item->pic_url,
    		'taobao_price'=>$item->price,
    		'taobao_click_url'=>$item->click_url,
	    	'taobao_commission'=>$item->commission,
	    	'taobao_commission_rate'=>$item->commission_rate,
	    	'taobao_commission_num'=>$item->commission_num,
	    	'taobao_commission_volume'=>$item->commission_volume,
	    	'taobao_shop_click_url'=>$item->shop_click_url,
	    	'taobao_seller_credit_score'=>$item->seller_credit_score,
	    	'taobao_volume'=>$item->volume
    	);
    	if($this->isRepeat($item->num_iid)){
    		$this->insert($data);
    	}
    }
    
    public function updateStatus($newStatus,$num_iid){
    	$this->update(array('item_status'=>$newStatus), "taobao_num_iid='".$num_iid."'");
    }
    
    public function isRepeat($num_iid){
    	$res=$this->fetchRow("taobao_num_iid='".$num_iid."'");
    	if($res){
    		return false;
    	}
    	return true;
    }

}

